#!/usr/bin/php
<?

function phpSatDir( $dir ) {

	$dh = opendir( $dir );

	while ( $file = readdir($dh) ) {
		$path = "$dir/$file";
		if ( !preg_match('/^\\./',$file) )
			if ( is_dir($path) )
				phpSatDir( $path );
			else {
				$data = `php-sat -r 5 -i $path`;
				$lines = split( "\n", $data );
				for ( $i=0; $i<sizeof($lines); $i++ ) {
					if ( preg_match('/PHP-SAT check \((.*)\)/',$lines[$i],$matches) ) {
						$type = $matches[ 1 ];
						preg_match( '/Description: (.*)/', $lines[$i+2], $matches );
						$desc = $matches[ 1 ];
						echo "==========================\n" .
							"File: $path\n" .
							"Line: $i\n" .
							"Type: $type\n" .
							"Desc: $desc\n" .
							"==========================\n\n";
					}
					$count++;
				}
			}
	}

	closedir( $dh );

}

phpSatDir( 'release/library/Smutty' );

?>